//
//  UIBarButtonItem+WENExtension.m
//  仿百思不得姐
//
//  Created by wen on 2018/2/9.
//  Copyright © 2018年 wen. All rights reserved.
//

#import "UIBarButtonItem+WENExtension.h"

@implementation UIBarButtonItem (WENExtension)

+ (instancetype)itemWithImageNamed:(NSString *)imageName target:(id)target action:(SEL)action {

    //设置左边按钮
    UIButton *btn = [[UIButton alloc] init];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    //拼接字符串,获取高亮状态图片名称
    NSString *heightLightImageName = [imageName stringByAppendingString:@"-click"];
    [btn setImage:[UIImage imageNamed:heightLightImageName] forState:UIControlStateHighlighted];
    btn.bounds = CGRectMake(0, 0, btn.currentImage.size.width, btn.currentImage.size.height);
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc] initWithCustomView:btn];

}


@end
